# include <stdio.h>
int main ()
{
	int n,x,t;
	scanf("%d",&n);
	while(n--)
	{
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
        for(x=1000;x<=9999;x++)
        {
		if(x%a==0&&(x+1)%b==0&&(x+2)%c==0)
        {
        t=1;
        break;}
		else
		t=0;}
		if(t==0)
		printf("Impossible\n");
		else if(t==1)
		printf("%d\n",x);

	 } 

		return 0;
	
}

